package com.yl.service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.yl.dao.IOrdersDao;
import com.yl.dto.OrdersDTO;
import com.yl.model.Orders;
@Service
public class OrdersService implements IOrdersService {

	@Resource
	private IOrdersDao ordersDao;

	/**
	 *前台新增订单
	 */
	public int add(Orders orders) {
		return ordersDao.add(orders);
	}

	/**后台查询订单列表
	 *
	 */
	@Override
	public Map findAllorders(OrdersDTO o) {
		List<Orders> list = ordersDao.findAllorders(o);
		Map<String,Object> map = new HashMap<String, Object>();
		map.put("code", 0);
		map.put("count", ordersDao.getCount(o));
		map.put("data", list);
		return map;
	}

	/**
	 *后台查询未发货订单
	 */
	@Override
	public Map findPayOrder() {
		List<Orders> list = ordersDao.findPayOrder();
		Map<String,Object> map = new HashMap<String, Object>();
		map.put("code", 0);
		map.put("count", list.size());
		map.put("data", list);
		return map;
	}
	
	/**
	 *后台查询发货订单
	 */
	@Override
	public Map findFaOrder() {
		List<Orders> list = ordersDao.findFaOrder();
		Map<String,Object> map = new HashMap<String, Object>();
		map.put("code", 0);
		map.put("count", list.size());
		map.put("data", list);
		return map;
	}

	/**
	 *购物车数量
	 */
	@Override
	public int getCount(OrdersDTO o) {		
		return ordersDao.getCount(o);
	}
}
